package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.common.constants.RedisConstants;
import com.ytjj.common.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/app_config")
@Slf4j
public class ConfigNewAppLifeHallIndexController {
    @Autowired
    private RedisService redisService;

    @GetMapping("/update")
    public CommonResult updateRedisConfig(@RequestParam(value = "type") Integer type,
                                          @RequestParam(value = "key", required = false) String key,
                                          @RequestParam(value = "value") String value) {
        log.info("===app_config.update==={},{},{}", type, key, value);
        switch (type) {
            case 1:
                redisService.set(RedisConstants.CONFIG_ACTIVITYTYPES_APP, value);
                break;
            case 11:
                redisService.set(RedisConstants.PRODUCT_ACTIVITY_TITLE + key, value);
                break;
            case 12:
                redisService.set(RedisConstants.PRODUCT_ACTIVITY_IMG + key, value);
                break;
            case 13:
                redisService.set(RedisConstants.PRODUCT_ACTIVITY_DESC + key, value);
                break;
            case 2:
                redisService.set(RedisConstants.CONFIG_FORUM_APP, value);
                break;
            case 21:
                redisService.set(RedisConstants.PRODUCT_FORUM_TITLE + key, value);
                break;
            case 22:
                redisService.set(RedisConstants.PRODUCT_FORUM_IMG + key, value);
                break;
            case 23:
                redisService.set(RedisConstants.PRODUCT_FORUM_DESC + key, value);
                break;
        }
        return CommonResult.success();
    }
}
